﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace CoreGallery.Core.Framework
{
    public class CoreList<T> : Collection<T>
    {
        public event EventHandler<ItemInsertedArgs<T>> ItemAdded;

        protected override void InsertItem(int index, T item)
        {
            EventHandler<ItemInsertedArgs<T>> handler = ItemAdded;
            if (handler != null)
            {
                handler(this, new ItemInsertedArgs<T>(index, item));
            }
            base.InsertItem(index, item);
        }
    }

    public class ItemInsertedArgs<T> : EventArgs
    {
        public int Index;
        public T Item;

        public ItemInsertedArgs(int index, T item)
        {
            this.Index = index;
            this.Item = item;
        }
    }
}
